package com.thirtydays.frame.util

import android.content.Context
import com.blankj.utilcode.util.LogUtils
import com.blankj.utilcode.util.StringUtils
import com.scwang.smart.refresh.footer.ClassicsFooter
import com.scwang.smart.refresh.header.ClassicsHeader
import com.tencent.bugly.crashreport.CrashReport
import com.thirtydays.frame.R
import com.thirtydays.frame.constant.*
import com.xm.bluetoothkotlin.BluetoothManager

/**
 * @创建者:小垚
 * @时间:2021/10/15
 *@描述: 第三方初始化工具
 */
object LibraryHelp {

    fun init(context: Context) {
        initBug(context)
        initLog()
        initRefresh(context)
        initBluetooth(context)
    }

    private fun initBluetooth(context: Context) {
        BluetoothManager.init(context)
    }

    private fun initBug(context: Context) {
        // 这里实现SDK初始化，appId替换成你的在Bugly平台申请的appId
        // 调试时，将第三个参数改为true
        CrashReport.initCrashReport(context, CRASHREPORT_APPID, true);
    }

    private fun initLog() {
        var config = LogUtils.getConfig()
        config.isSingleTagSwitch = true
        config.isLogSwitch = true
        config.setBorderSwitch(true)
        config.globalTag = StringUtils.getString(R.string.app_name)
        config.isLogHeadSwitch = true
    }

    /**
     * 刷新 新增多语言设置
     */
    private fun initRefresh(context: Context) {
        ClassicsHeader.REFRESH_HEADER_PULLING = context.getString(R.string.xialakeyishuaxin)
        ClassicsHeader.REFRESH_HEADER_REFRESHING = context.getString(R.string.zhengzaishuaxin)
        ClassicsHeader.REFRESH_HEADER_LOADING = context.getString(R.string.zhengzaijiazhai)
        ClassicsHeader.REFRESH_HEADER_RELEASE = context.getString(R.string.shifangshuaxin)
        ClassicsHeader.REFRESH_HEADER_FINISH = context.getString(R.string.shuanxinwancheng)
        ClassicsHeader.REFRESH_HEADER_FAILED = context.getString(R.string.shuaxinshibai)
        ClassicsHeader.REFRESH_HEADER_UPDATE = context.getString(R.string.shangcigengxin)
        ClassicsFooter.REFRESH_FOOTER_PULLING = context.getString(R.string.shanglajiazhaigengduo)
        ClassicsFooter.REFRESH_FOOTER_RELEASE = context.getString(R.string.shifanglijijiazhai)
        ClassicsFooter.REFRESH_FOOTER_REFRESHING = context.getString(R.string.zhengzaishuaxin)
        ClassicsFooter.REFRESH_FOOTER_LOADING = context.getString(R.string.zhengzaijiazhai)
        ClassicsFooter.REFRESH_FOOTER_FINISH = context.getString(R.string.jiazhaiwancheng)
        ClassicsFooter.REFRESH_FOOTER_FAILED = context.getString(R.string.jiazhaoshibai)
        ClassicsFooter.REFRESH_FOOTER_NOTHING = context.getString(R.string.quanbujiazhaiwancheng)
    }
}